<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Examples Philosophy</title>
</head>

<body>

<h2>Examples Philosophy</h2>

<p>JBehave was developed as behaviour-driven and example-driven. 
As such, examples are an integral part of the build, since they act as automated acceptance criteria verifying the correctness of the 
JBehave's behaviour.  The examples are run as integration tests, complementing the behaviour verified by unit tests.</p>

<span class="followup">Examples could also be called Behaviours, as they represent integration-level behaviours.  
</span>

<h2>src/main or src/test?</h2>

<p>A recurring question that is often asked is where one should place the behaviour code, in <b>src/main</b> or <b>src/test</b>. 
The answer is largely a matter of convention and depends on the build system you are using.</p>

<p>In Maven, <b>src/test</b> tends to be used for unit testing and anything found in the test directory is not packaged in the artifact 
being built.  Also, <b>src/test</b> conventionally tests only the code contained in that module.  
This is why it is recommendable for integration testing to have a separate module 
and to place the behaviour code in <b>src/main</b>.  This allows the integration testing module to verify the behaviour of multiple 
production modules and it also allows the modularisation of the integration testing itself.</p>

<p>That said, JBehave allows the running of stories from either <b>src/main</b> or <b>src/test</b> (the behaviour is controlled by
the <b>scope=[main|test]</b> property of the Ant/Maven configuration). So it's down the the user preference where to place the behaviour code.</p>

<span class="followup">The examples modules contain a mix of stories/steps classes as well as other code used in the running of the examples.  
This code is functional to the testing and should be thought of as "test code".  It constitutes a test harness that verifies the "production 
code" that is found in the JBehave core modules.
</span>

<div class="clear">
<hr />
</div>


</body>
</html>
